#!/bin/sh

awk '
BEGIN {
   print "# Write seconds\tMByte/s" > "output_write.dat"
   print "# Read seconds\tMByte/s" > "output_read.dat"
}

/write time/ { printf("%s\t", $4) >> "output_write.dat" }
/read time/ { printf("%s\t", $4) >> "output_read.dat" }

/write speed/ { printf("%s\n", $4) >> "output_write.dat" }
/read speed/ { printf("%s\n", $4) >> "output_read.dat" }
'


gnuplot -persist -e "

   set term png giant size 1280,1024;
   set output \"output.png\";
   set multiplot layout 2,2;
   set xlabel \"samples\";
   set ylabel \"time (s)\";
   plot \"output_write.dat\" using 1 title \"Time for Writing\";
   set ylabel \"MByte/s\";
   plot \"output_write.dat\" using 2 title \"Write Disk Throughput\";
   set ylabel \"time (s)\";
   plot \"output_read.dat\" using 1 title \"Time for Reading\";
   set ylabel \"MByte/s\";
   plot \"output_read.dat\" using 2 title \"Read Disk Throughput\";
   unset multiplot;
"

eog *.png
